<template>
  <el-input v-bind="$attrs" v-on="$listeners" v-model="fieldValue"  :style="width">
    <template slot="prepend" v-if="$attrs.prepend">{{$attrs.prepend}}</template>
    <template slot="append" v-if="$attrs.append">{{$attrs.append}}{{appValue}}</template>
  </el-input>
</template>

<script>
import { getParent} from '../utils'
import { getPropByPath } from 'element-ui/src/utils/util'
  export default {
    props: {
      value: {
        type: [String,Number],
        default:'0.00'
      }
    },
    data(){
      return {
         width:'100%',
         appValue:this.value
         
      }
    },
    computed: {
      parent() {
        return getParent.call(this)
      },
      fieldValue: {
        get() {
          if(this.$attrs.width) {
              this.width = 'width:'+this.$attrs.width;
          }

          if(this.$attrs.appenName) {
            const model = this.parent.currentModel

            if (model) {
                this.appValue = getPropByPath(model, this.$attrs.appenName.toString(), true).v

            }
          }
          
          if(this.appValue === this.value) {
                return '';
          }else{
            return this.value;
          }
          
        },
        set(val) {
          this.$emit('input', val)
        }
      }
    },
  }
</script>


